/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/


#include "stdafx.h"
#include <pgl/algotools/STLMatrix.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

namespace std
{

template <>
bool TSTLMatrix<double>::NormRows()
{
	ASSERT(size()==m_iM*m_iN);
	UINT i,j;
	double sum;
	for (i=0;i<m_iM;i++)
	{
		sum=0;
		for (j=0;j<m_iN;j++)
		{
			sum+=at(i*m_iN+j);
		}
		if (sum == 0)
			return false;

		for (j=0;j<m_iN;j++)
		{
			at(i*m_iN+j)/=sum;
		}
	}
	return true;
}

};
